package com.lai.hospital.controller;


import com.lai.hospital.dto.SystemBackInfoDTO;
import com.lai.hospital.service.SystemHomeService;
import com.lai.hospital.service.impl.WebSocketServiceImpl;
import com.lai.hospital.strategy.context.UploadStrategyContext;
import com.lai.hospital.vo.Result;
import com.lai.hospital.vo.VoiceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 系统主页控制器
 *
 */
@Api(tags = "系统主页模块")
@RestController
public class SystemHomeController {
    @Autowired
    private SystemHomeService systemHomeService;
    @Autowired
    private WebSocketServiceImpl webSocketService;
    @Autowired
    private UploadStrategyContext uploadStrategyContext;

    /**
     * 查看后台信息
     *
     * @return {@link Result<SystemBackInfoDTO>} 后台信息
     */
    @ApiOperation(value = "查看后台信息")
    @GetMapping("/admin")
    public Result<SystemBackInfoDTO> getSystemBackInfo() {
        return Result.ok(systemHomeService.getSystemBackInfo());
    }


    /**
     * 保存语音信息
     *
     * @param voiceVO 语音信息
     * @return {@link Result<String>} 语音地址
     */
    @ApiOperation(value = "上传语音")
    @PostMapping("/voice")
    public Result<String> sendVoice(VoiceVO voiceVO) {
        webSocketService.sendVoice(voiceVO);
        return Result.ok();
    }

    /**
     * 上传访客信息
     *
     * @return {@link Result}
     */
    @PostMapping("/report")
    public Result<?> report() {
        systemHomeService.report();
        return Result.ok();
    }

}

